export async function ajaxJson(url: string): Promise<any> {
  new Promise((resolve, reject) => {
    let request: XMLHttpRequest
    //1【创建】
    if (window.XMLHttpRequest) {
      request = new XMLHttpRequest()
    } else {
      // @ts-ignore
      request = new ActiveXObject('Microsoft.XMLHTTP')
    }

    //2: 【连接】true:表示异步
    request.open('GET', url, true)

    //3：【发送】
    request.send()

    //4：【接受】
    request.onreadystatechange = function () {
      // 判断浏览器操作到哪一步
      if (request.readyState == 4) {// 4：读取完成
        if (request.status == 200) {
          resolve(JSON.parse(request.responseText))
        } else {
          if (reject) {
            reject(request.status)
          }
        }
      }
    }
  })
}
